const http = require('http');
const url = require('url');

const server = http.createServer((request,response)=> {
  // 解析request的url
  let res = url.parse(request.url, true)
  // 路径
  let pathname = res.pathname;
  // 查询字符串
  // console.log(res)
  let a = res.query.a;
  let b = res.query.b;
  console.log(pathname);
  console.log(a,b);

  // 设置响应体
  response.setHeader('content-type','text/html;charset=utf-8')
  response.end('返回url')
})

server.listen(9000,()=> {
  console.log('项目启动中...')
})


// 浏览器打开这个测试： http://localhost:9000/search?a=1&b=3